﻿@model  List<Classes>
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Add</title>
    <link href="~/css/bootstrap.css" rel="stylesheet" />
    <script src="~/js/jquery-1.10.2.js"></script>
   <script type="text/javascript">
       $(function () {
           $('#btnAdd').click(function () {
               //var name = $('#Name').val();
               var dataForm = $('#addForm').serializeArray();
               $.ajax({
                   url: '/student/Add',  /*请求的路径，在这就是某一个action*/
                   type: 'post', /*提交方式为post提交*/
                   data: dataForm,
                   dataType: 'json', /*服务器给浏览器返回的数据的格式*/
                   success: function (e) {
                       //服务器成功处理请求后，在这里里面需要做的一些回应或者操作
                       if (e == 'ok') {
                           alert('成功');    
                           window.location.href = '/student/list';
                       }
                       else {
                           alert('失败');
                       }
                       
                   },
                   error: function () {
                       alert('网络异常');
                   }


               });


           });


       })
   </script>
</head>
<body>
    <form id="addForm">
        <div class="form-horizontal">
            <hr />
            <h2 style="margin-left:460px">添加学员信息</h2>
            <div class="form-group">
                <div class="col-md-3">

                </div>
                <div class="col-md-3">
                    <input type="text" class="form-control" placeholder="姓名" name="Name" id="Name" />
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-3">

                </div>
                <div class="col-md-3">
                    <input type="text" class="form-control" placeholder="性别" name="Sex" id="Sex" />
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-3">

                </div>
                <div class="col-md-3">
                    <input type="text" class="form-control" placeholder="年龄" name="Age" />
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-3">

                </div>
                <div class="col-md-3">
                    <input type="text" class="form-control" placeholder="手机号" name="Mobile" />
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-3">

                </div>
                <div class="col-md-3">
                    <input type="text" class="form-control" placeholder="邮箱地址" name="Email" />
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-3">

                </div>
                <div class="col-md-3">
                    @*<input type="text" class="form-control" placeholder="班级" name="ClassId" />*@
                    @Html.DropDownList("ClassId", new SelectList(Model, "id", "className"), new { @class = "form-control" })
                </div>

            </div>
            <div class="form-group">
                <div class="col-md-3">

                </div>
                <div class="col-md-8">
                    <input type="button" value="添加学员" id="btnAdd" class="btn btn-default" />
                </div>
            </div>

        </div>
    </form>
</body>
</html>
